******************
**** Figure C3 ***
******************

use "$data/stickerpromptsurvey" , clear



** Data prep **
gen manipulation=0 if q1a==1 // People who see sticker for the first time vs saw sticker at home 
replace manipulation=1 if q1a==2

gen q2bALT=q2b
replace q2bALT=4 if identitylabel==0 & manipulation==0 // This corrects for the fact that people who saw a basic sticker at home cannot recall an identity label. 6549/9842 = 0,6645% received an Identity label

foreach var in q2a q2bALT q2c q2d {
gen bar`var'=0 if `var'!=.
replace bar`var'=1 if `var'<3 & `var'!=.
}

foreach var in q5a q5b q5c q5d q5e {
gen bar`var'=0 if `var'!=.
replace bar`var'=1 if `var'<2 & `var'!=.
}


** Acceptability of stickers ** BASIC vs PIDA
tab barq5a identitylabel if identitylabel!=1, chi
tab barq5b identitylabel if identitylabel!=1, chi
tab barq5c identitylabel if identitylabel!=1, chi
tab barq5d identitylabel if identitylabel!=1, chi
tab barq5e identitylabel if identitylabel!=1, chi

** Acceptability of stickers ** BASIC vs NIDA

tab barq5a identitylabel if identitylabel!=2, chi
tab barq5b identitylabel if identitylabel!=2, chi
tab barq5c identitylabel if identitylabel!=2, chi
tab barq5d identitylabel if identitylabel!=2, chi
tab barq5e identitylabel if identitylabel!=2, chi


collapse (mean) barq2a barq2bALT barq2c barq2d barq5a barq5b barq5c barq5d barq5e (sebinomial) sebarq2a=barq2a sebarq2bALT=barq2b sebarq2c=barq2c sebarq2d=barq2d sebarq5a=barq5a sebarq5b=barq5b sebarq5c=barq5c sebarq5d=barq5d sebarq5e=barq5e,  by(identitylabel)
foreach var of varlist barq2a barq2bALT barq2c barq2d barq5a barq5b barq5c barq5d barq5e {
gen lb`var'=`var'-se`var'
gen ub`var'=`var'+se`var'
}


gen z1=1 if barq5a!=.
gen z2=1 if barq5b!=.
gen z3=1 if barq5c!=.
gen z4=1 if barq5d!=.
gen z5=1 if barq5e!=.

gen identitylabel2=identitylabel+4 
gen identitylabel3=identitylabel+8
gen identitylabel4=identitylabel+12
gen identitylabel5=identitylabel+16

bysort identitylabel: sum barq5a barq5b barq5c barq5d barq5e


twoway ///
    (bar barq5a identitylabel if z1==1 & identitylabel==0, color(gs14) lcolor(black) barwidth(0.95) bargap(2) ) ///
    (bar barq5a identitylabel if z1==1 & identitylabel==1, color(gs7) lcolor(black) barwidth(0.95) bargap(2)) ///
    (bar barq5a identitylabel if z1==1 & identitylabel==2, color(gs2) lcolor(black) barwidth(0.95) bargap(2)) ///
    (rcap lbbarq5a ubbarq5a identitylabel if z1==1, lcolor(black)) ///
    (bar barq5b identitylabel2 if z2==1 & identitylabel2==4, color(gs14) lcolor(black) barwidth(0.95)) ///
    (bar barq5b identitylabel2 if z2==1 & identitylabel2==5, color(gs7) lcolor(black) barwidth(0.95)) ///
    (bar barq5b identitylabel2 if z2==1 & identitylabel2==6, color(gs2) lcolor(black) barwidth(0.95)) ///
    (rcap lbbarq5b ubbarq5b identitylabel2 if z2==1, lcolor(black)) ///
    (bar barq5c identitylabel3 if z3==1 & identitylabel3==8, color(gs14) lcolor(black) barwidth(0.95)) ///
    (bar barq5c identitylabel3 if z3==1 & identitylabel3==9, color(gs7) lcolor(black) barwidth(0.95)) ///
    (bar barq5c identitylabel3 if z3==1 & identitylabel3==10, color(gs2) lcolor(black) barwidth(0.95)) ///
    (rcap lbbarq5c ubbarq5c identitylabel3 if z3==1, lcolor(black)) ///
    (bar barq5d identitylabel4 if z4==1 & identitylabel4==12, color(gs14) lcolor(black) barwidth(0.95)) ///
    (bar barq5d identitylabel4 if z4==1 & identitylabel4==13, color(gs7) lcolor(black) barwidth(0.95)) ///
    (bar barq5d identitylabel4 if z4==1 & identitylabel4==14, color(gs2) lcolor(black) barwidth(0.95)) ///
    (rcap lbbarq5d ubbarq5d identitylabel4 if z4==1, lcolor(black)) ///
    (bar barq5e identitylabel5 if z5==1 & identitylabel5==16, color(gs14) lcolor(black) barwidth(0.95)) ///
    (bar barq5e identitylabel5 if z5==1 & identitylabel5==17, color(gs7) lcolor(black) barwidth(0.95)) ///
    (bar barq5e identitylabel5 if z5==1 & identitylabel5==18, color(gs2) lcolor(black) barwidth(0.95)) ///
    (rcap lbbarq5e ubbarq5e identitylabel5 if z5==1, lcolor(black)) ///
    , yla(0(0.1)0.85) ///
      xlabel(1 "Useful and good" 5 "Encouraging" 9 "Informative" 13 "Demanding/offending" 17 "Cautioning", noticks labsize(small)) ///
      ytitle("Fraction that fully agrees", size(msmall)) ///
     legend( ///
    row(1) ///
    order(1 "Basic" 5 "PIDA" 9 "NIDA") ///
    label(1 "Basic", col(gs12)) ///
    label(5 "PIDA", col(gs7)) ///
    label(9 "NIDA", col(gs2))) ///
      graphregion(color(white)) ///
      title("Impression of the sticker by treatments", color(black))

	  
graph export "$filepath/output_logs/figure c3.pdf", replace

